#ifndef KMNETSERVER_H
#define KMNETSERVER_H

#include <iostream>
#include <string>
#include <list>
#include <enet/enet.h>
#include "KMNetConnectedClient.h"
#include "KMNetMsgIn.h"

class KMNetConnectedClient;
class KMNetMsgIn;

class KMNetServer
{
public:
    KMNetServer();
    virtual ~KMNetServer();
    bool listenTo(unsigned int port);
    void stopListen();
    void update(unsigned int timeout = 0);

protected:
    std::list<KMNetConnectedClient*> mConnectedClients;
    virtual void clientConnected(KMNetConnectedClient *client) = 0;
    virtual void clientDisconnected(KMNetConnectedClient *client) = 0;
    virtual void processMessageFromClient(KMNetConnectedClient *client, KMNetMsgIn &msg) = 0;

private:
    ENetHost *mHost;
    ENetAddress mAddress;
};

#endif
